package com.ayoka.mvp;

import com.ayoka.R;
import com.ayoka.base.BasePresenter;
import com.ayoka.base.IBaseView;
import com.ayoka.mvp.TrainingDetailMVP.TrainingDetailModel.TrainingQuestionBean;
import com.ayoka.mvp.TrainingDetailMVP.TrainingDetailModel.TrainingQuestionOptionBean;
import com.ayoka.mvp.TrainingPrepareMVP.TrainingPrepareModel.TrainingQuestionMultiEntity;
import com.jcp.baselibrary.brvah.entity.MultiItemEntity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by gabriel on 2017/3/5.
 */

public interface TrainingPrepareMVP {

    interface TrainingPrepareModel {

        class TrainingQuestionMultiEntity extends MultiItemEntity {
            public static final int TITLE = 1;// 标题
            public static final int QUESTION = 2;// 问题
            public static final int OPTION = 3;// 选项
            public static final int BUTTON = 4;// 按钮

            public TrainingQuestionMultiEntity(int itemType, Object object) {
                super(itemType, object);
            }
        }
    }

    interface ITrainingPrepareView extends IBaseView {

        void configTrainingQuestion(List<TrainingQuestionMultiEntity> listData);
    }

    class TrainingPreparePresenter extends BasePresenter<ITrainingPrepareView> {


        public void formatQuestion(TrainingQuestionBean trainingQuestionBean) {
            List<TrainingQuestionMultiEntity> result = new ArrayList<>();
            result.add(new TrainingQuestionMultiEntity(TrainingQuestionMultiEntity.TITLE, R.string.haba_meditation_prepare));
            result.add(new TrainingQuestionMultiEntity(TrainingQuestionMultiEntity.QUESTION, trainingQuestionBean.Question));
            if (trainingQuestionBean.Options != null && !trainingQuestionBean.Options.isEmpty()){
                for (TrainingQuestionOptionBean option : trainingQuestionBean.Options) {
                    result.add(new TrainingQuestionMultiEntity(TrainingQuestionMultiEntity.OPTION, option));
                }
            }
            result.add(new TrainingQuestionMultiEntity(TrainingQuestionMultiEntity.BUTTON, null));
            mViewRef.get().configTrainingQuestion(result);
        }
    }
}
